<template>
  <div class="container" v-if="!showEdit">
    <div class="title">
      <span>分销明细</span>
      <span class="back" @click="back">
        <i class="iconfont icon-fanhui"></i> 返回
      </span>
    </div>
    <el-divider></el-divider>
    <el-table stripe v-loading="loading" :data="tableData">
      <el-table-column prop="id" label="奖励类别id" width="120"></el-table-column>
      <el-table-column prop="category_name" label="奖励类别" width="240"></el-table-column>
      <el-table-column prop="create_time" label="创建时间" width="300"></el-table-column>
      <el-table-column prop="money" label="金额" min-width="200" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="is_need" label="是否需要提现" min-width="200" :show-overflow-tooltip="true">
        <template slot-scope="scopes">
          <el-tag
            type="danger"
            effect="dark"
            v-if="scopes.row.is_need==='需要'"
          >{{ scopes.row.is_need }}</el-tag>
          <el-tag
            type="success"
            effect="dark"
            v-if="scopes.row.is_need==='不需要'"
          >{{ scopes.row.is_need }}</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import Distribution from '@/model/distribution'


export default {
  props: {
    distributionId: {
      type: Number,
    },
  },
  data() {
    return {
      loading: false,
      form: {
        name: '',
        title: '',
        description: '',
      },
      tableData: [],
      mainMaxNum: 1,
      initData: [],
      isCreate: false,
      showEdit: false,
      editID: 0,
    }
  },
  async mounted() {
    this.loading = true
    this.getDetail()
    this.loading = false
  },
  methods: {
    // async getValue() {
    //   const val = await this.$refs.uploadEle.getValue()
    //   if (val && val.length > 0) {
    //     this.form.img = val[0].display
    //   }
    // },
    async getDetail() {
      const res = await Distribution.getDetailDistribution(this.distributionId)
      console.log(res, 'res')
      res.distribution_list.forEach(item => {
        if (item.is_success === 0) {
          item.is_need = '需要'
        } else {
          item.is_need = '不需要'
        }
        item.money = `${item.money / 100}元`
      })
      this.tableData = res.distribution_list
      this.form = res
      this.initData = [{ id: res.id, display: res.img }]
      this.bannerItems = res.items
    },
    back() {
      this.$emit('detailClose')
    },
  },
}
</script>

<style lang="scss" scoped>
.el-divider--horizontal {
  margin: 0;
}

.container {
  .title {
    height: 59px;
    line-height: 59px;
    color: $parent-title-color;
    font-size: 16px;
    font-weight: 500;
    text-indent: 40px;
    .add-btn {
      margin-left: 30px;
    }

    .back {
      float: right;
      margin-right: 40px;
      cursor: pointer;
    }
  }

  .wrap {
    padding: 20px;
  }

  .submit {
    float: left;
  }

  .inner-container {
    margin-bottom: 50px;
  }
}
.col {
  display: flex;
  justify-content: space-between;
}
</style>
